package
{
	import flash.utils.*;
	
	import org.flixel.*;
	
	import states.*;
	
	/**
	 * ...
	 * @author JAC
	 */
	public class PauseScreen extends FlxGroup
	{
		public var disabled:Boolean;
		
		private var _overlay:FlxSprite;
		private var _text:FlxText;
		
		public function PauseScreen():void
		{
			Registry.paused = false;
			
			disabled = false;
			
			_overlay = new FlxSprite(200, 175);
			_overlay.makeGraphic(325, 175, 0x88000000);
			_overlay.exists = false;
			
			_text = new FlxText(265, 220, FlxG.width, "This game is PAUSED!\n\nPress ENTER to resume\nPress ESC for main menu\nPress R to restart level");
			_text.font = "cooper_black";
			_text.size = 15;
			_text.exists = false;
			
			add(_overlay);
			add(_text);
		}
		
		override public function update():void
		{
			if (disabled)
			{
				return;
			}
			
			if (FlxG.keys.justPressed("ENTER"))
			{
				Registry.paused = !Registry.paused;
				_overlay.exists = !_overlay.exists;
				_text.exists = !_text.exists;
			}
		}
		
		public static function add():PauseScreen
		{
			var p:PauseScreen = new PauseScreen();
			FlxG.state.add(p);
			return p;
		}
		
		public function returnToMainMenu():Boolean
		{
			if (disabled)
			{
				return false;
			}
			
			return FlxG.keys.justPressed("ESCAPE");
		}
		
		public function restartLevel():Boolean
		{
			if (disabled)
			{
				return false;
			}
			
			return FlxG.keys.justPressed("R");
		}
	}
}